﻿using System;
using System.Threading;
using Newtonsoft.Json;

namespace PubSub.S2
{
    public class BaseHandler
    {
        public FuncTypeEnum FuncType { get; protected set; } = FuncTypeEnum.Default;

        public virtual void Execute(RedisPubSubMessage message)
        {
            Console.WriteLine($"未能处理类型：{nameof(BaseHandler1)}\tmessage:{JsonConvert.SerializeObject(message)}");
        }
    }

    public class BaseHandler1 : BaseHandler
    {
        public BaseHandler1()
        {
            base.FuncType = FuncTypeEnum.Test1;
        }

        public override void Execute(RedisPubSubMessage message)
        {
            Console.WriteLine($"{nameof(BaseHandler1)}\tmessage:{JsonConvert.SerializeObject(message)}");
        }
    }

    public class BaseHandler2 : BaseHandler
    {
        public BaseHandler2()
        {
            base.FuncType = FuncTypeEnum.Test2;
        }

        public override void Execute(RedisPubSubMessage message)
        {
            Console.WriteLine($"{nameof(BaseHandler2)}\tmessage:{JsonConvert.SerializeObject(message)}");
        }
    }

   
}